package com.kang.mapper;

import com.kang.model.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

/**
 * Created by Administrator on 2018/1/10.
 */

/*@Mapper*/
@CacheConfig(cacheNames = "student")
public interface  StudentMapper {

    @Select("select * from student where id = #{id}")
    Student getUserById(Integer id);

    @Select("select * from student")
    public List<Student> getStudentList();

    @Insert("insert into student(age,name) values(#{age}, #{name})")
    public int add(Student student);

    @Update("update student set age = #{student.age},name = #{student.name} where id = #{id}")
    public int update(Integer id, Student student);

    @Delete("delete from student where id = #{id} ")
    public int delete(Integer id);

    @Select("select * from student where name = #{name} and password = #{password}")
    public Student findStdByNameAndPwd(@Param("name") String name, @Param("password") String pwd);

    @Cacheable(key = "#p0")
    @Select("select * from student where name = #{name}")
    List<Student> findStdByName(@Param("name") String name);
}
